home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / cycles / init-pos.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.8 KB  |  68 lines

  1. /*
  2.  * setup init positions and speeds etc of the cycles
  3.  */
  4.  
  5. #include <stdio.h>    /* for sprintf */
  6. #include <stdlib.h>   /* for rand, RAND_MAX */
  7. #include <bstring.h>  /* for bcopy */
  8. #include "cycles.h"
  9.  
  10. extern CYCLE *good, bike[CYCLES];
  11. extern int used[CYCLES];
  12. extern float vec[4][2];
  13.  
  14. static int num_names = 8;
  15. static char *namelist[] = { "walter", "alan san", "sarah", "brett",
  16.                             "claire", "nick", "ernie", "james" };
  17.  
  18. void init_pos(CYCLE *C) {
  19.     int i;
  20.  
  21.     /*
  22.      * if you want to start in the same spot every time
  23.      * put the code here in place of the next 3 lines
  24.      */
  25.     C->origin.x = 1.8*DIM*(float)rand()/(float)RAND_MAX - 0.9*DIM;
  26.     C->origin.y = HEIGHT;
  27.     C->origin.z = 1.8*DIM*(float)rand()/(float)RAND_MAX - 0.9*DIM;
  28.  
  29.     C->step = 0.8*MIN_STEP + 0.2*MAX_STEP;
  30.     C->jump = 0;
  31.     C->jump_speed = 0.0;
  32.     C->fall = 0.0;
  33.     C->falling = 0;
  34.     C->vec_ptr = rand()%4;
  35.     C->direction.x = vec[C->vec_ptr][0];
  36.     C->direction.y = 0.0;
  37.     C->direction.z = vec[C->vec_ptr][1];
  38.     C->alive = 1;
  39.     C->who_we_hit = -1;
  40.     C->quit = 0;
  41.     C->level = rand()%LEVELS;
  42.     C->type = ROBOT;
  43.     C->lturn = 0;
  44.     C->rturn = 0;
  45.     C->behave = rand()%2;
  46.     C->trail_colour = rand()%6;
  47.     sprintf(C->name, "%s", namelist[rand()%num_names]);
  48.     C->trail_ptr = 0;
  49.  
  50. #if 0
  51.     C->origin.x = 0.1*DIM*(float)rand()/(float)RAND_MAX - 0.9*DIM;
  52.     C->origin.y = HEIGHT;
  53.     C->origin.z = 0.1*DIM*(float)rand()/(float)RAND_MAX - 0.9*DIM;
  54.     C->step = MIN_STEP;
  55.     C->level = 0;
  56. #endif
  57.  
  58.     for (i = 0; i < TRAIL_LENGTH; i++) {
  59.     C->trail[i].y = 0.0;
  60.     C->trail[i].x = C->origin.x;
  61.     C->trail[i].z = C->origin.z;
  62.     C->trail[i].level = -1;
  63.     }
  64.     C->trail[0].level = C->level;
  65.     bcopy((void *)&C->trail[0], (void *)&C->trail_update, (int)sizeof(POINT));
  66.     C->view = vadd(C->origin, C->direction);
  67. }
  68.